<template>
  <div class='container'>
    <el-form ref="chkform">
      <el-form-item
        label=""
        style="text-align:left"
        prop="chkState"
      >
        <el-radio-group v-model="form.chkState">
          <el-radio :label="1">通过</el-radio>
          <el-radio :label="2">拒绝</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        label=""
        prop="chkRemarks"
      >
        <el-input
          type="textarea"
          v-model.trim="form.chkRemarks"
          placeholder="请输入意见"
        ></el-input>
      </el-form-item>
    </el-form>
    <span>
      <el-button @click="hClose">取 消</el-button>
      <el-button
        @click="hSubmit"
        type="primary"
      >确 定</el-button>
    </span>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  props: {
    formChk: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      form: {
        id: 0,
        chkState: 0, // 审核状态
        chkRemarks: '' // 意见
      }
    }
  },
  created () {
    console.log(this.formChk)
    this.form.chkState = this.formChk.chkState
    this.form.id = this.formChk.id
  },
  methods: {
    // 取消
    hClose () {
      this.$emit('close')
    },
    async hSubmit () {
      try {
        if (this.form.chkRemarks === '') {
          this.$message.warning('请输入意见')
          return
        }
        const res = await choiceCheck(this.form)
        console.log(res)
        this.$message.success('操作成功')
        this.$emit('update')
      } catch (err) {
        this.$message.error('操作失败')
      }
    }
  }
}
</script>

<style scoped lang='less'></style>
